//
//  DetailCell.m
//  Travel_M_Travel
//
//  Created by dlios on 15-3-27.
//  Copyright (c) 2015年 lanou3g.com 蓝鸥科技. All rights reserved.
//

#import "DetailCell.h"
#import "UIImageView+WebCache.h"
#import "PlayController.h"
@implementation DetailCell

- (void)dealloc
{
    [_title release];
    [_coverSmall release];
    [_likes release];
    [_playtimes release];
    [super dealloc];
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.bigBtn = [UIButton buttonWithType:UIButtonTypeSystem];
//        self.bigBtn.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height/2);
//        self.bigBtn.backgroundColor = [UIColor redColor];
        [self.bigBtn addTarget:self action:@selector(bigBtnAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_bigBtn];
        
        
        self.zan = [UIButton buttonWithType:UIButtonTypeSystem];
//        zan.frame = CGRectMake(0, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
        [_zan setTitle:@"赞" forState:UIControlStateNormal];
        [_zan addTarget:self action:@selector(zanAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_zan];
        
        self.pl = [UIButton buttonWithType:UIButtonTypeSystem];
//        pl.frame = CGRectMake(self.contentView.frame.size.width/3, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
        [_pl setTitle:@"评论" forState:UIControlStateNormal];
        [_pl addTarget:self action:@selector(plAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_pl];
        
        self.xg = [UIButton buttonWithType:UIButtonTypeSystem];
//        xg.frame = CGRectMake(self.contentView.frame.size.width*2/3, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
        [_xg setTitle:@"下载" forState:UIControlStateNormal];
        [_xg addTarget:self action:@selector(xgAction:) forControlEvents:UIControlEventTouchUpInside];
        [self.contentView addSubview:_xg];
        
        
        self.coverSmall = [[UIImageView alloc] init];
        _coverSmall.backgroundColor = [UIColor redColor];
        [self.bigBtn addSubview:_coverSmall];
        [_coverSmall release];
        
        self.title = [[UILabel alloc] init];
        self.title.font = [UIFont systemFontOfSize:14];
        [self.bigBtn addSubview:_title];
        [_title release];
     
        self.likesImg = [[UIImageView alloc] init];
        [self.bigBtn addSubview:_likesImg];
        [_likesImg release];
        
        self.likes = [[UILabel alloc] init];
        self.likes.font = [UIFont systemFontOfSize:10];
        [self.bigBtn addSubview:_likes];
        [_likes release];
        
        self.playtimesImg = [[UIImageView alloc] init];
        [self.bigBtn addSubview:_playtimesImg];
        [_playtimesImg release];
        
        self.playtimes = [[UILabel alloc] init];
        self.playtimes.font = [UIFont systemFontOfSize:10];
        [self.bigBtn addSubview:_playtimes];
        [_playtimes release];
        

    }
    return self;
}

- (void)xgAction:(UIButton *)xg
{

}

- (void)plAction:(UIButton *)pl
{

}

- (void)zanAction:(UIButton *)zan
{

}

- (void)layoutSubviews
{
    [super layoutSubviews];
    
//    self.bigBtn = [UIButton buttonWithType:UIButtonTypeSystem];
//    self.bigBtn.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height*3/4);
//    [self.bigBtn addTarget:self action:@selector(bigBtnAction:) forControlEvents:UIControlEventTouchUpInside];
//    [self.contentView addSubview:_bigBtn];
    
    self.bigBtn.frame = CGRectMake(0, 0, self.contentView.frame.size.width, self.contentView.frame.size.height*2/3);
     self.zan.frame = CGRectMake(0, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
     self.pl.frame = CGRectMake(self.contentView.frame.size.width/3, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
      self.xg.frame = CGRectMake(self.contentView.frame.size.width*2/3, self.contentView.frame.size.height/4*3, self.contentView.frame.size.width/3, self.contentView.frame.size.height/4);
    
    self.coverSmall.frame = CGRectMake(self.contentView.frame.size.width*4/5-20, 0, 60, 60);
    NSString *str = self.track.coverSmall;
    str = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    NSURL *url = [NSURL URLWithString:str];
    [self.coverSmall setImageWithURL:url];
    
    self.title.frame = CGRectMake(50, 20, self.contentView.frame.size.width/2+30, self.contentView.frame.size.height/5);
    self.title.text = self.track.title;
    
    self.likesImg.frame = CGRectMake(60, 43, 10, 10);
    self.likesImg.image = [UIImage imageNamed:@"likes.png"];
    
    
    self.likes.frame = CGRectMake(70, 43, self.contentView.frame.size.width/15, self.contentView.frame.size.height/10);
    NSString *str1 = [NSString stringWithFormat:@"%@", self.track.likes];
    self.likes.text = str1;
    
    self.playtimesImg.frame = CGRectMake(90, 43, 10, 10);
    self.playtimesImg.image = [UIImage imageNamed:@"playtimes.png"];
    
    self.playtimes.frame = CGRectMake(100, 43, self.contentView.frame.size.width/10, self.contentView.frame.size.height/10);
    NSString *str2 = [NSString stringWithFormat:@"%@", self.track.playtimes];
    self.playtimes.text = str2;
}


- (void)bigBtnAction:(UIButton *)button
{
    PlayController *play = [[PlayController alloc] init];
    [self.detail.navigationController pushViewController:play animated:NO];
    [play release];
    
    
}
- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
